<template>
  <div>


    <table class="table1 owntable mb20 tableLayout" border="0" cellspacing="0" cellpadding="1" width="100%">
      <tr>
        <td width="150">采购品检验管理编号</td>
        <td>{{ item.number }}</td>
        <td width="150">采购类别</td>
        <td>{{ purchaseList[item.purchaseType] }}</td>
      </tr>
      <tr>
        <td>检验部门</td>
        <td>{{ item.manageDeptName }}</td>
        <td>检验员</td>
        <td>{{ item.manageUserName }}</td>
      </tr>
      <tr>
        <td>原材料批号</td>
        <td>{{ item.batchNumber || '-' }}</td>
        <td>检验日期</td>
        <td>{{ item.examinDate }}</td>
      </tr>
      <tr v-if="item.purchaseType == 1">
        <td>设备名称</td>
        <td>{{ item.deviceName }}</td>
        <td>设备编号</td>
        <td>{{ item.deviceNumber }}</td>
      </tr>
      <tr v-if="item.purchaseType == 2">
        <td>外包服务商名称</td>
        <td colspan="3">{{ item.outsourcingName }}</td>
      </tr>
      <tr v-if="item.purchaseType == 3">
        <td>计算机应用软件名称</td>
        <td>{{ item.softwareName }}</td>
        <td>计算机应用软件版本</td>
        <td>{{ item.softwareVersion }}</td>
      </tr>

      <tr>
        <td>合格数量</td>
        <td>{{ item.qualifiedQty }}</td>
        <td>不合格数量</td>
        <td>{{ item.failedQty }}</td>
      </tr>

      <tr>
        <td>检验日期</td>
        <td>{{ item.examinDate }}</td>
        <td>编制部门</td>
        <td>{{ item.createDeptName }}</td>
      </tr>
    </table>

    <template v-if="item.purchaseType == 0">
      <div class="mb20">原材料信息如下</div>

      <div v-for="(v, index) in item.materialList" :key="index">
        <table class="table1 owntable mb20 tableLayout" border="0" cellspacing="0" cellpadding="1" width="100%">
          <tr>
            <td>原材料名称</td>
            <td>{{ v.materialName }}</td>
            <td>原材料规格</td>
            <td>{{ v.materialSku }}</td>
          </tr>
          <tr>
            <td>原材料编号</td>
            <td>{{ v.materialNumber }}</td>
           <td>检验方式</td>
           <td>{{ v.examineType==0?'全部检验':'计数抽样检验' }}</td>
          </tr>
          <tr>
            <td>批量接收/批量拒收</td>
            <td>{{ v.isHege==0?'批量接收':'批量拒收' }}</td>
           <td>样品检验</td>
           <td><el-button type="primary" plain v-if="v.examineType==1">查看详情</el-button> <span v-else>-</span></td>
          </tr>
          <tr>
            <td>合格数量</td>
            <td>{{ v.qualifiedQty }} {{v.unit}}</td>
           <td>不合格数量</td>
           <td>{{ v.failedQty }} {{v.unit}}</td>
          </tr>
          <tr>
            <td>是否使用设备</td>
            <td colspan="3">
              <span>{{ v.deviceList && v.deviceList.length != 0 ? '是' : '否' }}</span>
              <el-button v-if="v.deviceList && v.deviceList.length > 3" class="ml30" type="primary" size="mini" plain @click="v.showmore = !v.showmore" >
                {{ v.showmore ? '收起设备详情' : '展开设备详情' }}
                <i :class="{ 'el-icon-arrow-down': !v.showmore, 'el-icon-arrow-up': v.showmore }"></i>
              </el-button>
            </td>
          </tr>
        </table>
        <table class="table1 owntable mb20 deviceCon tableLayout" border="0" cellspacing="0" cellpadding="1" width="100%" v-if="v.showmore">
          <tr>
            <td>设备名称</td>
            <td class="gray_bg">设备型号</td>
            <td>设备编号</td>
          </tr>
          <tr v-for="(m, i) in v.deviceList" :key="i">
            <td class="white_bg">{{ m.deviceName }}</td>
            <td>{{ m.deviceModel }}</td>
            <td class="white_bg">{{ m.deviceNumber }}</td>
          </tr>
        </table>
      </div>
    </template>
    <template v-if="item.purchaseType != 0">
      <table class="table1 owntable mb20 tableLayout" border="0" cellspacing="0" cellpadding="1" width="100%" v-if="item.deviceList &&item.deviceList.length!=0">
        <tr>
          <td>使用设备名称</td>
          <td class="gray_bg">设备型号</td>
          <td>设备编号</td>
        </tr>
        <tr v-for="(v, i) in item.deviceList" :key="i">
          <td class="white_bg">{{ v.deviceName }}</td>
          <td class="white_bg">{{ v.deviceModel }}</td>
          <td class="white_bg">{{ v.deviceNumber }}</td>
        </tr>
      </table>
    </template>

  </div>
</template>

<script>
export default {
  props: {
    item: {}
  },
  watch:{
    item:{
      handler(newval){
          console.log(newval)
          if(newval.purchaseType==0){
             newval.materialList.forEach(item=>{
               if(item.deviceList){
                 if(item.deviceList.length<=3){
                   item.showmore=true;
                 }else{
                   item.showmore=false;
                 }
               }
             })
          }
      }
    }
  }
};
</script>

<style></style>
